<?php
$conn = mysql_connect('localhost','root','');
if(!$conn){
    die('Could not connect..');
}

mysql_select_db('dbtraining',$conn);

$result = mysql_query('SELECT id, genre_name FROM genre');
if (mysql_num_rows($result) > 0) {
    while ($obj = mysql_fetch_object($result)) {
        $arr[] = $obj;
    }
}
echo '{rows:' . json_encode($arr) . '}';

mysql_close($conn);

//ini tambahan

?>
